stubdom: optimize block io completion polling by not polling all the
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 14 Feb 2008 09:23:14 +0000 (09:23 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 14 Feb 2008 09:23:14 +0000 (09:23 +0000)
time; only when some requests have completed.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
extras/mini-os/blkfront.c
tools/ioemu/block-vbd.c

index b83d5af34533fe6a35080422db10862a773c9452..1021bb018fd4145289c314a1f8787f69cde88e5c 100644 (file)
@@ -327,6 +327,11 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
     struct blkif_response *rsp;
 
 moretodo:
+#ifdef HAVE_LIBC
+    files[dev->fd].read = 0;
+    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+#endif
+
     rp = dev->ring.sring->rsp_prod;
     rmb(); /* Ensure we see queued responses up to 'rp'. */
     cons = dev->ring.rsp_cons;
index 9cb97255e68e23c833d3c3b4eae39ff50336bf66..5561cf1787a108162f2505715c0d95c29cd2fc6b 100644 (file)
@@ -67,6 +67,12 @@ static int vbd_probe(const uint8_t *buf, int buf_size, const char *filename)
     return 100;
 }
 
+static void vbd_io_completed(void *opaque)
+{
+    BDRVVbdState *s = opaque;
+    blkfront_aio_poll(s->dev);
+}
+
 static int vbd_open(BlockDriverState *bs, const char *filename, int flags)
 {
     BDRVVbdState *s = bs->opaque;
@@ -85,6 +91,7 @@ static int vbd_open(BlockDriverState *bs, const char *filename, int flags)
     }
 
     s->fd = blkfront_open(s->dev);
+    qemu_set_fd_handler(s->fd, vbd_io_completed, NULL, s);
 
     QEMU_LIST_INSERT_HEAD(&vbds, s, list);
 
@@ -102,9 +109,6 @@ void qemu_aio_init(void)
 
 void qemu_aio_poll(void)
 {
-    BDRVVbdState *s;
-    for (s = vbds.lh_first; s; s = s->list.le_next)
-       blkfront_aio_poll(s->dev);
 }
 
 /* Wait for all IO requests to complete.  */